package abi

import (
	"github.com/mitchellh/mapstructure"
	"ruoyi-go/app/utils"
)

type AbiParse struct{}

func (parse *AbiParse) Parse(key string) interface{} {
	maps := utils.ReadLocalJson(key)
	// WEB3_ABI[key] =
	// TODO
	return maps
}

func ParseAbi(maps map[string]interface{}) {
	i := maps["abi"]
	m := i.([]interface{})
	func_list := make([]interface{}, 1)
	for _, v := range m {
		m2 := v.(map[string]interface{})
		if m2["type"] == "function" {
			func_list = append(func_list, v)
		}
	}

	for _, v := range func_list {
		if v != nil {
			var tmp Function
			mapstructure.Decode(v, &tmp)
			WEB3_ABI[tmp.Name] = tmp
		}

	}
}
